using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;

namespace BUS
{
   public  class tbDonHangBUS
    {
        public static void Insert(tbDonHang donhang)
        {
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            donhangDAL.Insert(donhang);

        }
        public static void Uptate(tbDonHang donhang)
        {
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            donhangDAL.Update(donhang);

        }
        public static void Delete(int iD)
        {
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            donhangDAL.Delete(iD);
        }
        public static tbDonHangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            return donhangDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDonHangCollection GetAll()
        {
            int total = 0;
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            return donhangDAL.Get("where 1=1", 0, 0,
            tbDonHangColumns.MaDH .ToString(),
            "ASC", out total);
        }
        public static tbDonHang GetByID(int iD)
        {
            int total = 0;
            tbDonHangDAL donhangDAL = new tbDonHangDAL();
            tbDonHangCollection donhangCollection = donhangDAL.Get("where " +
            tbDonHangColumns.MaDH .ToString() + "=" + iD.ToString(),
            0, 0, tbDonHangColumns.MaDH .ToString(), "ASC", out total);
            if (donhangCollection.Count > 0)
                return donhangCollection[0];
            return null;
        }
    }
}
